<?php 
    session_start();
    include_once 'inc/db.class.php'; 
    include_once 'inc/function.php'; 
?>
<!DOCTYPE html>
<html>

	<head lang="en">
	     
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		 <?php include_once 'meta.php'; ?>
		<meta name="format-detection" content="telephone=no">
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />

		<link rel="stylesheet" href="assets/css/amazeui.css" />
		<link href="css/dlstyle.css" rel="stylesheet" type="text/css">
		<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script>
		<script src="layer/layer.js"></script>
		<script>
			$(document).ready(function(){
				$("#login").click(function(){
					var pre=/^[a-zA-Z0-9_]{5,18}$/;  //账号正则
					var pre2=/^1[3456789]\d{9}$/;  //手机正则
					var pre3=/^[a-zA-Z0-9]+\@[a-zA-Z0-9]+\.[a-zA-Z0-9]+$/;
					if(!pre.test($("#username").val()) && !pre2.test($("#username").val()) && !pre3.test($("#username").val())){
						layer.msg("用户格式错误",{icon:3});
						return;
					}
					if(!pre.test($("#userpwd").val())){
						layer.msg("密码格式错误",{icon:3});
						return;
					}
					$.ajax({
						url:"ajax/login.php",
						type:"post",
						data:{"username":$("#username").val(),"userpwd":$("#userpwd").val(),"rember":$("#rember-me").val()},
						success:function(data){
							if(data==1){
								location.href='index.php';
							}else if(data==2){
								layer.msg("用户名或者密码错误",{icon:5});
							}else{
								layer.msg("登录失败",{icon:5});
							}
						},
						error:function(){
							layer.msg("登录失败",{icon:2});
						}
					});
				});
			});
		</script>
	</head>

	<body>

		<div class="login-boxtitle">
			<a href="index.php"><img alt="logo" src="images/<?php echo $web["logo"]; ?>"/></a>
		</div>

		<div class="login-banner">
			<div class="login-main">
				<div class="login-banner-bg"><span></span><img src="images/big.jpg" /></div>
				<div class="login-box">

							<h3 class="title">登录商城</h3>

							<div class="clear"></div>
						
						<div class="login-form">
						  <form>
							   <div class="user-name">
								    <label for="user"><i class="am-icon-user"></i></label>
								    <input value="<?php echo isset($_COOKIE["uname"]) ? $_COOKIE["uname"] : ""; ?>" type="text" name="username" id="username" placeholder="邮箱/手机/用户名">
                 </div>
                 <div class="user-pass">
								    <label for="password"><i class="am-icon-lock"></i></label>
								    <input type="password" name="userpwd" id="userpwd" placeholder="请输入密码">
                 </div>
              </form>
           </div>
            
            <div class="login-links">
                <label for="remember-me"><input id="rember-me" type="checkbox">记住账号</label>
								<a href="#" class="am-fr">忘记密码</a>
								<a href="register.php" class="zcnext am-fr am-btn-default">注册</a>
								<br />
            </div>
								<div class="am-cf">
									<input type="submit" name="" id="login" value="登 录" class="am-btn am-btn-primary am-btn-sm">
								</div>
						<div class="partner">		
								<h3>合作账号</h3>
							<div class="am-btn-group">
								<li><a href="#"><i class="am-icon-qq am-icon-sm"></i><span>QQ登录</span></a></li>
								<li><a href="#"><i class="am-icon-weibo am-icon-sm"></i><span>微博登录</span> </a></li>
								<li><a href="#"><i class="am-icon-weixin am-icon-sm"></i><span>微信登录</span> </a></li>
							</div>
						</div>	

				</div>
			</div>
		</div>

        <?php include_once 'footer.php'; ?>
	</body>

</html>